import './App.css';

//rcc 生成类组件
//rsf 生成函数式组件
// 懒加载组件导入
import React, { Component, lazy, Suspense } from 'react';
// 路由组件导入
import { Route, Redirect, Switch } from 'react-router-dom';


// 懒加载

var Index = lazy(() => import('./views/Index'))
var Login = lazy(() => import('./views/Login'))
var Register = lazy(() => import('./views/Register'))
var NotFound = lazy(() => import('./views/NotFound'))
var Serach = lazy(() => import('./views/Serach'))
var ShouCang = lazy(() => import('./views/ShouCang'))
var Detail = lazy(() => import('./views/Detail'))
var Much = lazy(() => import('./views/Much'))
var New = lazy(() => import('./views/New'))
class App extends Component {
  render() {
    return (
      <div className='app'>
        <Suspense>
          <Switch>
            <Route path="/index" component={Index} />
            <Route exact path="/login" component={Login} />
            <Route exact path="/register" component={Register} />
            <Route exact path="/notfound" component={NotFound} />
            <Route exact path="/serach" component={Serach} />
            <Route exact path="/shoucang" component={ShouCang} />
            <Route exact path="/detail" component={Detail} />
            <Route exact path="/much" component={Much} />
            <Route exact path="/new" component={New} />
            <Redirect exact from='/' to="/index" />
            <Route path="*" component={NotFound} />
          </Switch>
        </Suspense>
      </div>
    );
  }
}

export default App;